package org.blame.rabbitmqadvancedfeature.config;

import org.blame.rabbitmqadvancedfeature.constant.Constants;
import org.springframework.amqp.core.*;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class QosConfig {
    @Bean("qosQueue")
    public Queue qosQueue(){
        return QueueBuilder.durable(Constants.QOS_QUEUE).build();
    }
    @Bean("qosExchange")
    public DirectExchange qosExchange(){
        return ExchangeBuilder.directExchange(Constants.QOS_EXCHANGE).delayed().build();
    }

    @Bean("qosBlinding")
    public Binding qosBlinding(@Qualifier("qosQueue") Queue queue,
                                 @Qualifier("qosExchange") DirectExchange directExchange){
        return BindingBuilder.bind(queue).to(directExchange).with("qos");
    }
}
